//
//  ActivityDetailViewController.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/3/28.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "ActivityDetailViewController.h"
#import "NJKWebViewProgressView.h"
#import "SharePopView.h"
@interface ActivityDetailViewController ()
@property (strong, nonatomic) IBOutlet UIView *navView;

@end

@implementation ActivityDetailViewController
{
    NJKWebViewProgressView *_progressView;
    NJKWebViewProgress *_progressProxy;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navgationView addSubview:_progressView];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [_progressView removeFromSuperview];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
    // Do any additional setup after loading the view.
    if (self.titleStr) {
        if([self.titleStr isEqualToString:@"积分商品详情"]){
            [self.navgationTitleLabel setTitle:self.titleStr forState:UIControlStateNormal];
        }
    }
    
    [self loadData];
}

- (void)initViewLayout{

    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.webView];
    
}

- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}

#pragma mark == 分享
- (IBAction)shareHandel:(id)sender {
    SharePopView * popView = [[SharePopView alloc]initWithTitles:@[@"微信好友",@"朋友圈",@"新浪微博",@"QQ好友"] complect:^(NSInteger index) {
    switch (index) {
        case 0:
            {
                [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatSession] content:@"" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                    if (response.responseCode == UMSResponseCodeSuccess) {
                        //            NSLog(@"分享成功！");
                    }
                }];
                
            }
            break;
        case 1:
            {
                [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:@"" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                    if (response.responseCode == UMSResponseCodeSuccess) {
                        //            NSLog(@"分享成功！");
                    }
                }];
            }
            break;
        case 2:
            {
                [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToSina] content:@"" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                    if (response.responseCode == UMSResponseCodeSuccess) {
                        //            NSLog(@"分享成功！");
                    }
                }];
            }
            break;
        case 3:
            {
                [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQQ] content:@"" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                    if (response.responseCode == UMSResponseCodeSuccess) {
                        //            NSLog(@"分享成功！");
                    }
                }];
            }
            break;
        default:
            break;
        }
    }];
    [popView show];
}


//活动详情
-(void)loadData{
    if (self.titleStr) {
        if([self.titleStr isEqualToString:@"积分商品详情"]){
            NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@?goodsId=%@",IP_Address_WEB,SX_ueryContext,self.objectId]]];
            [_webView loadRequest:req];
        }
    }else{
        NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@?avitiId=%@",IP_Address_WEB,SX_queryActivityDetail,self.objectId]]];
        [_webView loadRequest:req];
    }
    
    
}
#pragma mark - NJKWebViewProgressDelegate
-(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress
{
    [_progressView setProgress:progress animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
